﻿using System;
using Litografia.BusinessEntities;

namespace Litografia.UI.Reports
{
    public partial class ReporteOTParametrosForm : BaseForm
    {
        #region Declarations

        #endregion

        #region Constructor

        public ReporteOTParametrosForm()
        {
            InitializeComponent();
            toolStrip.Visible = false;
        }

        #endregion

        #region Properties: Public

        public DateTime? BeginDate { get; set; }
        public DateTime? EndDate { get; set; }
        public string WorkOrder { get; set; }
        public string Status { get; set; }
        public string StatusName { get; set; }

        #endregion

        #region Event Handlers

        private void PrintButton_Click(object sender, EventArgs e)
        {
            if (datesInSearchCheck.Checked)
            {
                BeginDate = beginDate.Value.Date;
                EndDate = endDate.Value.Date;
            }
            WorkOrder = numberTextBox.Text.Trim();
            Status = ((BEEntity)statusComboBox.SelectedItem).Id;
            StatusName = ((BEEntity) statusComboBox.SelectedItem).Nombre;
        }

        private void ReporteOTParametrosForm_Load(object sender, EventArgs e)
        {
            PopulateStatusComboBox(statusComboBox);

            beginDate.Value = DateTime.Today;
            endDate.Value = DateTime.Today;
        }

        private void datesInSearchCheck_CheckedChanged(object sender, EventArgs e)
        {
            ToggleDates();
        }

        #endregion

        #region Methods: Non-Public
        
        private void ToggleDates()
        {
            beginDate.Enabled = datesInSearchCheck.Checked;
            endDate.Enabled = datesInSearchCheck.Checked;
        }

        #endregion
    }
}
